home *** CD-ROM | disk | FTP | other *** search
/ boe.pres.k12.wv.us / boe.pres.k12.wv.us.zip / boe.pres.k12.wv.us / Utilities / Xerox Workcentre 5335 / Windows Utilities / Font Management Utility / ChineseS / Xerox Font Management Utility.msi / Data1.cab / fmu.chm3 / skinsupport / madcapeffectsmenu.js < prev    next >
Text File  |  2011-04-21  |  11KB  |  402 lines

  1. /// <reference path="MadCapUtilities.js" />
  2.  
  3. // {{MadCap}} //////////////////////////////////////////////////////////////////
  4. // Copyright: MadCap Software, Inc - www.madcapsoftware.com ////////////////////
  5. ////////////////////////////////////////////////////////////////////////////////
  6. // <version>6.1.0.0</version>
  7. ////////////////////////////////////////////////////////////////////////////////
  8.  
  9. function FMCSetClass(node, className)
  10. {
  11.     node.className = className;
  12.     
  13.        for ( i = 0; i < node.childNodes.length; i++ )
  14.     {
  15.         var child = node.childNodes[i];
  16.         FMCBroadcastNodeText(node, child);
  17.     }
  18. }
  19.  
  20. function FMCBroadcastNodeText(node, child)
  21. {
  22.     if( child.style == null) return;
  23.         
  24.          child.style.color = FMCGetComputedStyle( node, "color" );
  25.         child.style.fontFamily = FMCGetComputedStyle( node, "fontFamily" );
  26.         child.style.fontSize = FMCGetComputedStyle( node, "fontSize" );
  27.         child.style.fontStyle = FMCGetComputedStyle( node, "fontStyle" );
  28.         child.style.fontVariant = FMCGetComputedStyle( node, "fontVariant" );
  29.         child.style.fontWeight = FMCGetComputedStyle( node, "fontWeight" );
  30.         child.style.textDecoration = FMCGetComputedStyle( node, "textDecoration" );
  31.         child.style.textTransform = FMCGetComputedStyle(node, "textTransform" );     
  32.  
  33.        for ( i = 0; i < child.childNodes.length; i++ )
  34.     {
  35.         var grandchild = child.childNodes[i];
  36.     
  37.         FMCBroadcastNodeText(node, grandchild);
  38.     }
  39. }
  40.  
  41. function FMCSelectCell(node, select)
  42. {
  43.     var cell = FMCFindCell(node);
  44.     var table = FMCFindTable(cell);
  45.             
  46.     if(cell == table.MCSelectedCell) 
  47.     {
  48.         if( !select)
  49.         {
  50.             FMCSetClass(table.MCSelectedCell, "MCKLinkBodyCell");
  51.             table.MCSelectedCell = null;
  52.             return;
  53.        } 
  54.        
  55.        return;
  56.     }
  57.  
  58.     if( !select)
  59.     {
  60.         return;
  61.     }
  62.     
  63.     if(table.MCSelectedCell != null)
  64.     {
  65.         FMCSetClass(table.MCSelectedCell, "MCKLinkBodyCell");
  66.         table.MCSelectedCell = null;
  67.     }
  68.     
  69.     table.MCSelectedCell = cell;
  70.     
  71.     if(table.MCSelectedCell != null)
  72.     {
  73.         FMCSetClass(table.MCSelectedCell, "MCKLinkBodyCell_Highlighted");
  74.     }
  75. }
  76.  
  77. function FMCFindTable(node)
  78. {
  79.     if(node.nodeName == "TABLE") return node;
  80.     
  81.     return FMCFindTable(node.parentNode);
  82. }
  83.  
  84. function FMCFindCell(node)
  85. {
  86.     if(node.nodeName == "TD" || node.nodeName == "TH") return node;
  87.     
  88.     return FMCFindCell(node.parentNode);
  89. }
  90.  
  91. function FMCLinkControl( e, node, styleMap )
  92. {
  93.     // Don't continue if something is already popped up
  94.     
  95.     if ( gPopupObj )
  96.     {
  97.         return;
  98.     }
  99.     
  100.     if ( !e )
  101.     {
  102.         e = window.event;
  103.     }
  104.  
  105.     var clientX    = FMCGetClientX( window, e );
  106.     var clientY    = FMCGetClientY( window, e );
  107.     var pageX    = FMCGetPageX( window, e );
  108.     var pageY    = FMCGetPageY( window, e );
  109.         
  110.     var args    = { node: node, clientX: clientX, clientY: clientY, pageX: pageX, pageY: pageY, styleMap: styleMap };
  111.     
  112.     GetHelpControlLinks( node, OnGetHelpControlLinks, args );
  113. }
  114.  
  115. function OnGetHelpControlLinks( topics, args )
  116. {
  117.     var node        = args.node;
  118.     var klinkBody    = document.createElement( "div" );
  119.     var table        = document.createElement( "table" );
  120.     var tbody        = document.createElement( "tbody" );
  121.     
  122.     //
  123.     
  124.     var headerDiv    = document.createElement( "div" );
  125.     headerDiv.style.textAlign = "right";
  126.     headerDiv.style.fontSize = "1px";
  127.     headerDiv.style.padding = "2px";
  128.     
  129.     if ( args.styleMap != null )
  130.     {
  131.         var bgColor    = args.styleMap.GetItem( "backgroundColor" );
  132.         
  133.         if ( bgColor != null )
  134.         {
  135.             headerDiv.style.backgroundColor = bgColor;
  136.         }
  137.     }
  138.     
  139.     var closeImg    = document.createElement( "img" );
  140.     closeImg.style.width = "13px";
  141.     closeImg.style.height = "13px";
  142.     closeImg.style.marginRight = "1px";
  143.     //closeImg.onclick = FMCOnHelpControlCloseImageClick;
  144.     
  145.     var src = null;
  146.     
  147.     if ( MCGlobals.InPreviewMode )
  148.     {
  149.         var previewFolder = FMCGetAttribute( document.documentElement, "MadCap:previewFolder" );
  150.         
  151.         src = previewFolder + MCGlobals.SkinTemplateFolder + "CloseButton.gif";
  152.     }
  153.     else
  154.     {
  155.         src = MCGlobals.RootFolder + MCGlobals.SkinTemplateFolder + "Images/CloseButton.gif";
  156.     }
  157.     
  158.     closeImg.src = src;
  159.     
  160.     headerDiv.appendChild( closeImg );
  161.     klinkBody.appendChild( headerDiv );
  162.     
  163.     //
  164.     
  165.     klinkBody.className = "MCKLinkBody";
  166.     klinkBody.style.overflow = "auto";
  167.     klinkBody.MCOwner = node;
  168.     klinkBody.onkeyup = FMCKLinkBodyOnkeyup;
  169.     
  170.     table.style.border = "none";
  171.     table.style.margin = "0px";
  172.     table.style.padding = "0px";
  173.     table.style.borderCollapse = "collapse";
  174.     
  175.     //
  176.     
  177.     if ( topics.length == 0 )
  178.     {
  179.         topics = new Array( 1 );
  180.         topics[0] = "(No topics)|javascript:void( 0 );";
  181.     }
  182.     
  183.     FMCSortStringArray( topics );
  184.     
  185.     table.appendChild( tbody );
  186.     klinkBody.appendChild( table );
  187.     document.body.appendChild( klinkBody );
  188.     
  189.     for ( var i = 0; i < topics.length; i++ )
  190.     {
  191.         var topic    = topics[i].split( "|" );
  192.         var tr        = document.createElement( "tr" );
  193.         var td        = document.createElement( "td" );
  194.         var a        = document.createElement( "a" );
  195.  
  196.         td.onmouseover = function()
  197.         {
  198.             FMCSelectCell( this, true );
  199.             
  200.             if ( args.styleMap != null )
  201.             {
  202.                 var tdNode    = this;
  203.                 
  204.                 args.styleMap.ForEach( function( key, value )
  205.                 {
  206.                     if ( key.StartsWith( "hover", false ) )
  207.                     {
  208.                         var cssName    = key.substring( "hover".length );
  209.                         cssName = cssName.charAt( 0 ).toLowerCase() + cssName.substring( 1 );
  210.                         
  211.                         tdNode.style[cssName] = value;
  212.                     }
  213.                     
  214.                     return true;
  215.                 } );
  216.                 
  217.                 FMCBroadcastNodeText( tdNode, tdNode.getElementsByTagName( "a" )[0] );
  218.             }
  219.         };
  220.         
  221.         td.onmouseout = function()
  222.         {
  223.             if ( args.styleMap != null )
  224.             {
  225.                 var tdNode    = this;
  226.                 
  227.                 args.styleMap.ForEach( function( key, value )
  228.                 {
  229.                     if ( !key.StartsWith( "hover", false ) )
  230.                     {
  231.                         var cssName    = key.charAt( 0 ).toLowerCase() + key.substring( 1 );
  232.                         
  233.                         tdNode.style[cssName] = value;
  234.                     }
  235.                     
  236.                     return true;
  237.                 } );
  238.                 
  239.                 FMCBroadcastNodeText( tdNode, tdNode.getElementsByTagName( "a" )[0] );
  240.             }
  241.         };
  242.         
  243.         td.onclick = function()
  244.         {
  245.             FMCSelectCell( this, false );
  246.             
  247.             var inPreviewMode    = FMCInPreviewMode();
  248.             
  249.             if ( !inPreviewMode )
  250.             {
  251.                 var rootFrame    = FMCGetRootFrame();
  252.                 
  253.                 rootFrame.frames["body"].document.location.href = this.getElementsByTagName( "a" )[0].href;
  254.             }
  255.             else
  256.             {
  257.                 return false;
  258.             }
  259.         };
  260.         
  261.         a.appendChild( document.createTextNode( topic[0] ) );
  262.         a.href = topic[1];
  263.         a.target = "body";
  264.         
  265.         td.appendChild( a );
  266.         tr.appendChild( td );
  267.         tbody.appendChild( tr );
  268.         
  269.         if ( args.styleMap != null )
  270.         {
  271.             args.styleMap.ForEach( function( key, value )
  272.             {
  273.                 if ( !key.StartsWith( "hover", false ) )
  274.                 {
  275.                     var cssName    = key.charAt( 0 ).toLowerCase() + key.substring( 1 );
  276.                     
  277.                     td.style[cssName] = value;
  278.                 }
  279.                 
  280.                 return true;
  281.             } );
  282.             
  283.             FMCBroadcastNodeText( td, a );
  284.         }
  285.  
  286.         FMCSetClass( td, "MCKLinkBodyCell" );
  287.     }
  288.     
  289.     // "+ 5" is to account for width of popup shadow.
  290.     
  291.     var clientHeight    = FMCGetClientHeight( window, false );
  292.     var clientWidth        = FMCGetClientWidth( window, false );
  293.     
  294.     if ( klinkBody.offsetHeight + 5 > clientHeight )
  295.     {
  296.         klinkBody.style.height = (clientHeight - 5 - 2) + "px";    // "- 3" is to account for klinkBody borders.
  297.         //klinkBody.style.width = klinkBody.offsetWidth + 19 + "px";    // "+ 19" is to account for scrollbar.
  298.     }
  299.     
  300.     if ( klinkBody.offsetWidth + 5 > clientWidth )
  301.     {
  302.         klinkBody.style.width = (clientWidth - 5 - 2) + "px";    // "- 3" is to account for klinkBody borders.
  303.         //klinkBody.style.height = klinkBody.offsetHeight + 19 + "px";    // "+ 19" is to account for scrollbar.
  304.     }
  305.     
  306.     //
  307.     
  308.     var clientX    = 0;
  309.     var clientY    = 0;
  310.     var pageX    = 0;
  311.     var pageY    = 0;
  312.     
  313.     if ( node.MCKeydown )
  314.     {
  315.         if ( node.parentNode.style.position == "absolute" )
  316.         {
  317.             topOffset = document.getElementById( "searchField" ).offsetHeight;
  318.             
  319.             clientX = node.parentNode.offsetLeft - node.parentNode.parentNode.parentNode.scrollLeft;
  320.             clientY = node.parentNode.offsetTop - node.parentNode.parentNode.parentNode.scrollTop + topOffset;
  321.             pageX = node.parentNode.offsetLeft - node.parentNode.parentNode.parentNode.scrollLeft;
  322.             pageY = node.parentNode.offsetTop - node.parentNode.parentNode.parentNode.scrollTop + topOffset;
  323.         }
  324.         else
  325.         {
  326.             clientX = node.offsetLeft - FMCGetScrollLeft( window );
  327.             clientY = node.offsetTop - FMCGetScrollTop( window );
  328.             pageX = node.offsetLeft;
  329.             pageY = node.offsetTop;
  330.         }
  331.     }
  332.     else
  333.     {
  334.         clientX = args.clientX;
  335.         clientY = args.clientY;
  336.         pageX = args.pageX;
  337.         pageY = args.pageY;
  338.     }
  339.     
  340.     // "+ 5" is to account for width of popup shadow.
  341.     
  342.     if ( clientY + klinkBody.offsetHeight + 5 > FMCGetClientHeight( window, false ) )
  343.     {
  344.         klinkBody.style.top = FMCGetScrollTop( window ) + clientHeight - klinkBody.offsetHeight - 5 + "px";
  345.     }
  346.     else
  347.     {
  348.         klinkBody.style.top = pageY + "px";
  349.     }
  350.     
  351.     if ( clientX + klinkBody.offsetWidth + 5 > FMCGetClientWidth( window, false ) )
  352.     {
  353.         klinkBody.style.left = FMCGetScrollLeft( window ) + clientWidth - klinkBody.offsetWidth - 5 + "px";
  354.     }
  355.     else
  356.     {
  357.         klinkBody.style.left = pageX + "px";
  358.     }
  359.     
  360.     if ( node.MCKeydown )
  361.     {
  362.         klinkBody.getElementsByTagName( "a" )[0].focus();
  363.         node.MCKeydown = false;
  364.     }
  365.     
  366.     // Set up background
  367.     
  368.     var klinkBodyBG = document.createElement( "span" );
  369.     
  370.     klinkBodyBG.className = "MCKLinkBodyBG";
  371.     klinkBodyBG.style.top = parseInt( klinkBody.style.top ) + 5 + "px";
  372.     klinkBodyBG.style.left = parseInt( klinkBody.style.left ) + 5 + "px";
  373.     klinkBodyBG.style.width = klinkBody.offsetWidth + "px";
  374.     klinkBodyBG.style.height = klinkBody.offsetHeight + "px";
  375.     
  376.     klinkBody.parentNode.appendChild( klinkBodyBG );
  377.     
  378.     //
  379.     
  380. //    closeImg.MCHelpControl = klinkBody;
  381. //    closeImg.MCHelpControlBG = klinkBodyBG;
  382.  
  383.     MCFader.FadeIn( klinkBody, 0, 100, klinkBodyBG, 0, 50, true );
  384. }
  385.  
  386. //function FMCOnHelpControlCloseImageClick( e )
  387. //{
  388. //    this.MCHelpControl.parentNode.removeChild( this.MCHelpControl );
  389. //    this.MCHelpControlBG.parentNode.removeChild( this.MCHelpControlBG );
  390. //}
  391.  
  392. function FMCKLinkBodyOnkeyup( e )
  393. {
  394.     if ( !e ) { e = window.event; }
  395.     
  396.     if ( e.keyCode == 27 )
  397.     {
  398.         FMCClickHandler( e );
  399.         this.MCOwner.focus();
  400.     }
  401. }
  402.